using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Configuration;

namespace eVideoStore.DAL
{
    public class AbsDAOFactoriesFactory
    {
        private string sgbd="";
        private Assembly asm = null;
        private static AbsDAOFactoriesFactory uniqueInstance = null;

        private AbsDAOFactoriesFactory()
        {
            AppSettingsReader reader = new AppSettingsReader();
            sgbd = (string)reader.GetValue("sgbd", sgbd.GetType());
            asm = Assembly.Load(string.Format("eVideoStore.DAL.{0}", sgbd));
        }

        public static AbsDAOFactoriesFactory getInstance()
        {
            if (uniqueInstance == null)
            {
                uniqueInstance = new AbsDAOFactoriesFactory();
            }
            return uniqueInstance;
        }

        public DAOFactory buildDAOFactory()
        {
            return (DAOFactory)asm.CreateInstance(string.Format("eVideoStore.DAL.{0}.DAOFActory",sgbd));
        }
    }
}
